﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using Yipusoft.Account.BLL;
using Yipusoft.Evaluate.BLL;
using Yipusoft.Evaluate.Model;


public partial class Evaluate_AwardView : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGrid();
        }
    }
    private string GetDepartmentName2(string departmentID)
    {
        if (string.IsNullOrEmpty(departmentID))
            return "";

        if (departmentID.Length == 5 || departmentID.Length == 4)
            return Yipusoft.Account.BLL.Department.GetDepartment(departmentID.Substring(0, 4) + "000").FullName;
        if (departmentID.Length == 6)
            return Yipusoft.Account.BLL.Department.GetDepartment(departmentID + "0").FullName;
        if (departmentID.Length == 7)
            return Yipusoft.Account.BLL.Department.GetDepartment(departmentID).FullName;
        else
            return "";

    }
    private void BindGrid()
    {
        AwardInfo award = Award.GetAward(Convert.ToInt32(Request.QueryString["AwardID"]));
        string department = GetDepartmentName2(Request.QueryString["DepartmentID"]);
        UserGrid.Caption = "<span>" + award.AwardDate.Year.ToString() + "年" + award.AwardName + "工作奖惩加分情况统计表（" + department + "）</span>";
        List<AwardItemInfo> items = AwardItem.GetList("Left(DepartmentID,4)='" + Request.QueryString["DepartmentID"].Substring(0, 4) + "' and AwardID=" + Request.QueryString["AwardID"]);
        UserGrid.DataSource = items;
        UserGrid.DataBind();
    }
    protected void UserGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label ID = (Label)e.Row.FindControl("ID");
            ID.Text = (e.Row.RowIndex + 1).ToString();
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
        }
    }
    public string GetDepartmentName(string departmentID)
    {
        return Department.GetDepartment(departmentID).FullName;
    }
}
